#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include<string.h>
int main()
{
	const char *days[] = {"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"};
	int n;
	int i,j;
	scanf("%d", &n);
	for (i = 0; i < n; i++)
	{
		int found = -1;
		char a[10];
		scanf("%s", a);
		for (j = 0; j < 7; j++)
		{
			if (strcmp(a, days[j]) == 0)
			{
				found = j + 1;
				break;
			}
		}
		printf("%d\n", found);
	}
	return 0;
}